package com.platform.module.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.core.text.Convert;
import com.platform.module.domain.LinkSubValve;
import com.platform.module.mapper.LinkSubValveMapper;
import com.platform.module.service.ILinkSubValveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 集中器和阀门关联Service业务层处理
 *
 * @author wangqi
 * @date 2020-08-01
 */
@Service
public class LinkSubValveServiceImpl extends ServiceImpl<LinkSubValveMapper,LinkSubValve> implements ILinkSubValveService
{
    @Autowired
    private LinkSubValveMapper linkSubValveMapper;

    /**
     * 查询集中器和阀门关联列表
     *
     * @param linkSubValve 集中器和阀门关联
     * @return 集中器和阀门关联
     */
    @Override
    public List<LinkSubValve> selectLinkSubValveList(LinkSubValve linkSubValve)
    {
        return linkSubValveMapper.selectLinkSubValveList(linkSubValve);
    }

    /**
     * 新增集中器和阀门关联
     *
     * @param linkSubValve 集中器和阀门关联
     * @return 结果
     */
    @Override
    public int insertLinkSubValve(LinkSubValve linkSubValve)
    {
        return linkSubValveMapper.insert(linkSubValve);
    }

    /**
     * 修改集中器和阀门关联
     *
     * @param linkSubValve 集中器和阀门关联
     * @return 结果
     */
    @Override
    public int updateLinkSubValve(LinkSubValve linkSubValve)
    {
        linkSubValveMapper.delete(new QueryWrapper<LinkSubValve>().eq("valve_id", linkSubValve.getValveId()));
        return linkSubValveMapper.insert(linkSubValve);
    }

    /**
     * 删除集中器和阀门关联对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubValveByIds(String ids)
    {
        return linkSubValveMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除集中器和阀门关联信息
     *
     * @param valveId 集中器和阀门关联ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubValveById(String valveId)
    {
        return linkSubValveMapper.deleteById(valveId);
    }
}
